package com.ruoyi.face.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.face.domain.InoutRecord;
import com.ruoyi.face.service.IInoutRecordService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 出入人脸识别记录Controller
 * 
 * @author syv_fire
 * @date 2025-03-26
 */
@RestController
@RequestMapping("/faceRecord")
public class InoutRecordController extends BaseController
{
    @Autowired
    private IInoutRecordService inoutRecordService;

    /**
     * 查询出入人脸识别记录列表
     */
    @RequiresPermissions("face:faceRecord:list")
    @GetMapping("/list")
    public TableDataInfo list(InoutRecord inoutRecord)
    {
        startPage();
        List<InoutRecord> list = inoutRecordService.selectInoutRecordList(inoutRecord);
        return getDataTable(list);
    }

    /**
     * 导出出入人脸识别记录列表
     */
    @RequiresPermissions("face:faceRecord:export")
    @Log(title = "出入人脸识别记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InoutRecord inoutRecord)
    {
        List<InoutRecord> list = inoutRecordService.selectInoutRecordList(inoutRecord);
        ExcelUtil<InoutRecord> util = new ExcelUtil<InoutRecord>(InoutRecord.class);
        util.exportExcel(response, list, "出入人脸识别记录数据");
    }

    /**
     * 获取出入人脸识别记录详细信息
     */
    @RequiresPermissions("face:faceRecord:query")
    @GetMapping(value = "/{inOutRecordId}")
    public AjaxResult getInfo(@PathVariable("inOutRecordId") Long inOutRecordId)
    {
        return success(inoutRecordService.selectInoutRecordByInOutRecordId(inOutRecordId));
    }

    /**
     * 新增出入人脸识别记录
     */
    @RequiresPermissions("face:faceRecord:add")
    @Log(title = "出入人脸识别记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InoutRecord inoutRecord)
    {
        return toAjax(inoutRecordService.insertInoutRecord(inoutRecord));
    }

    /**
     * 修改出入人脸识别记录
     */
    @RequiresPermissions("face:faceRecord:edit")
    @Log(title = "出入人脸识别记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InoutRecord inoutRecord)
    {
        return toAjax(inoutRecordService.updateInoutRecord(inoutRecord));
    }

    /**
     * 删除出入人脸识别记录
     */
    @RequiresPermissions("face:faceRecord:remove")
    @Log(title = "出入人脸识别记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{inOutRecordIds}")
    public AjaxResult remove(@PathVariable Long[] inOutRecordIds)
    {
        return toAjax(inoutRecordService.deleteInoutRecordByInOutRecordIds(inOutRecordIds));
    }
}
